{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Find Cycles in a Graph\n",
    "\n",
    "[The Original Question](https://mp.weixin.qq.com/s/PDwZ4wim9MgKPSChL3uVNA)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Question\n",
    "\n",
    "Given an undirected graph, determine if a cycle exists in the graph."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "jupyter": {
     "source_hidden": true
    }
   },
   "outputs": [],
   "source": [
    "def find_cycle(graph: dict) -> bool:\n",
    "    # Fill this in.\n",
    "    pass\n",
    "\n",
    "\n",
    "graph = {\n",
    "    'a': {'a2':{}, 'a3':{} },\n",
    "    'b': {'b2':{}},\n",
    "    'c': {}\n",
    "}\n",
    "print(find_cycle(graph))\n",
    "graph['c'] = graph\n",
    "print(find_cycle(graph))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
